#include "stdafx.h"
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include "ado/PAbstracts.h"
#include "ado/DbMysql.h"

tDataBase tData;

PAbstracts::PAbstracts()
{
    tData.classname.erase();
    tData.database.erase();
    m_isnewcon = false;
}

PAbstracts::~PAbstracts()
{

}

int PAbstracts::setTableName(std::string name)
{
    tData.classname = name;
    return true;
}

int PAbstracts::setDatabaseName(std::string database)
{    
    m_isnewcon  = true;
    return true;
}

Selects *PAbstracts::find(const char *tokens, ...)
{
    va_list vp; 
    va_start(vp, tokens);
            
    Selects *sel;    
    sel = Selects::init(&tData)->find(tokens, vp);
    va_end(vp);
    return sel;
}

//插入
Inserts *PAbstracts::insertp(std::map<std::string, std::string> sets)
{
    Inserts *ins;
    
    ins = Inserts::init(&tData)->insertp(sets);    
    return ins;
}

//替换
Replaces *PAbstracts::replacep(std::map<std::string, std::string> sets)
{
    Replaces *rep;
    
    rep = Replaces::init(&tData)->replacep(sets);    
    return rep;
}

//更改
Updates *PAbstracts::setp(std::map<std::string, std::string> sets)
{
    Updates *upd;
    
    upd = Updates::init(&tData)->setp(sets);    
    return upd;
}

//删除
Deletes *PAbstracts::setv()
{
    Deletes *del;
    
    del = Deletes::init(&tData);
    return del;
}
